﻿<?php
require_once("../class2.php");
require_once(HEADERF);
require_once("./cms/includes/require_all.php");
ramka("open");

$username = USERNAME;

$q = "SELECT game_prefix FROM admin_panel";
$r = mysql_query($q);
$array_games_trans_tables = array();
while($a = mysql_fetch_array($r)){
	$v = (string)$a['game_prefix'];
	if(strlen($v) > 0){
		$array_games_trans_tables[] = $v;
	}
}

$arr = array();
foreach($array_games_trans_tables as $k => $v){
	$asd = array();
	$query = "select distinct translator_name from ".$v."_translations where status = 'Одобрен'";
	$result = mysql_query($query);
	while($array = mysql_fetch_array($result)){
		$br = 0;
		$q = "select * from ".$v."_translations where status = 'Одобрен' and translator_name = '".$array['translator_name']."'";
		$r = mysql_query($q);
		while($a = mysql_fetch_array($r)){
			$x = explode("\n", $a['translation']);
			clear_array($x);
			$br += count($x);
		}
		$asd[$array['translator_name']] = $br;
	}
	$z = $asd;
	foreach($z as $zz => $zzz){
		if(!array_key_exists($zz, $arr)){
			$arr[$zz] = $zzz;
		}
		else{
			$arr[$zz] += $zzz;
		}
	}
}

echo "<a href='index.php' style='font-size: 18px;'>НАЗАД</a><br><br>";

arsort($arr);
$br = 1;
echo "<table cellspacing='5' style='font-size: 16px;'>";
foreach($arr as $k => $v){
	if($k == USERNAME){
		echo "<tr style='color: green;'><td style='text-align: right;'>".$br.".</td><td>".$k."</td><td>".$v."</td></tr>";
	}
	else{
		echo "<tr><td style='text-align: right;'>".$br.".</td><td>".$k."</td><td>".$v."</td></tr>";
	}
	$br++;
}
echo "</table>";

ramka("close");
require_once(FOOTERF);
?>